package com.lirh.mysql.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lirh.mysql.dao.User1Dao;
import com.lirh.mysql.entity.User1Entity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.TimeUnit;

@Service
public class Uesr2Service {
    @Autowired
    private User1Dao user1Dao;


@Transactional
    public void test1(){

        try {
            TimeUnit.SECONDS.sleep(10);
            System.out.println("开始修改 id=24 的age");
        Wrapper<User1Entity> wrapper = new UpdateWrapper<>();
        user1Dao.update(null,((UpdateWrapper<User1Entity>) wrapper).eq("id",24).set("age",18));
            System.out.println("修改完成 id=24 的age");
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        throw new RuntimeException();

    }

}
